
//
// 110515 - AH - (Bybanen) Created.
// 110602 - AH - Added missing @author Laetitia Le Chatton.
// 110625 - AH - (Fotballpuben *) Change related to that hasContent method
//               moved from base class to Pit.
// 110703a- AH - (Hector) Missing java doc.
// 110703b- AH - (Hector) Changed link color from awful orange to blue.
//

package org.soekrat.gui.swing.chat.objectconversation;

import java.awt.BorderLayout;
import java.awt.Color;

import org.soekrat.engine.Soekrat2Engine;
import org.soekrat.engine.network.Cluster;
import org.soekrat.engine.network.Network;
import org.soekrat.engine.network.NetworkNode;
import org.soekrat.gui.swing.chat.objectconversation.NameCloudPane.Observer;

/**
 * <p>
 *   {@link ConversationComponent} that is for showing 
 *   {@link Network} retrieval.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
@SuppressWarnings("serial")
public final class NetworkConversationComponent extends ConversationComponent 
{
  private final NameCloudPane m_cp;
  
  private final Color m_defColor=Color.BLACK;
  
  private final Color m_linkColor=Color.BLUE;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param engine {@link Soekrat2Engine}.
   * @param c      {@link Cluster} retrieved.
   */
  public NetworkConversationComponent(Soekrat2Engine engine, Cluster c)
  {
    super(engine, "network");
    
    m_cp=new NameCloudPane(this);
    
    if (c==null)
    {
      throw new NullPointerException("c");
    }
    
    NetworkNode[] nodes=c.getNodes();
    for (NetworkNode curr : nodes)
    {
      String name=curr.getName();
      if (m_engine.getPit().hasContent(name, getOntology())) 
        m_cp.append(m_linkColor, name);
      else
        m_cp.append(m_defColor, name);
      m_cp.append(m_defColor, " ");
    }
     
    setLayout(new BorderLayout());
    add(m_cp, BorderLayout.CENTER);
    
    m_cp.setObserver
    (
      new Observer() 
      {
        public void selected(String word){ showContent(word); }
      }
    );
  }
  
}
